using MediatR;
using ProduceBasicData.Domain.WarehouseManage.WarehouseEnum;
using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Application.Command.WarehouseManage
{
    /// <summary>
    /// 创建出库单命令
    /// </summary>
    public class CreateStockOutOrderCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// 系统编码
        /// </summary>
        public string? OrderNumber { get; set; }

        /// <summary>
        /// 出库类型
        /// </summary>
        public StockOutType OutType { get; set; }

        /// <summary>
        /// 关联单号 (如生产单号、销售单号等)
        /// </summary>
        public string? RelatedOrderNumber { get; set; }

        /// <summary>
        /// 源仓库ID
        /// </summary>
        public int WarehouseId { get; set; }

        /// <summary>
        /// 客户ID
        /// </summary>
        public int? CustomerId { get; set; }

        /// <summary>
        /// 客户名称
        /// </summary>
        public string? CustomerName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public StockOutStatus Status { get; set; }

        /// <summary>
        /// 预计出库日期
        /// </summary>
        public DateTime? ExpectedOutDate { get; set; }

        /// <summary>
        /// 实际出库日期
        /// </summary>
        public DateTime? ActualOutDate { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 领料数量 赋值
        /// </summary>
        public int? Num { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string CreateName { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 出库单明细
        /// </summary>
        public List<CreateStockOutOrderItemCommand>? Items { get; set; }
    }

    /// <summary>
    /// 创建出库单明细命令
    /// </summary>
    public class CreateStockOutOrderItemCommand
    {
        /// <summary>
        /// 物料ID
        /// </summary>
        public int MaterialId { get; set; }

        /// <summary>
        /// 物料编号
        /// </summary>
        public string? MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string? MaterialName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string? Specification { get; set; }

        /// <summary>
        /// 出库数量
        /// </summary>
        public decimal Quantity { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string? Unit { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal UnitPrice { get; set; }

        /// <summary>
        /// 金额
        /// </summary>
        public decimal Amount { get; set; }

        /// <summary>
        /// 批次号
        /// </summary>
        public string? BatchNumber { get; set; }

        /// <summary>
        /// 库位ID
        /// </summary>
        public int LocationId { get; set; }
    }
}